<?php

namespace App\Http\Controllers\Article;

use Carbon\Carbon;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Article;

class ArticleController extends Controller
{
    //
    public function showlist(){
        $article=new Article();
//        $article->create(["title"=>"卢哥","content"=>"sb"]);
        $articles=Article::all();
        return view('articles.showlist')->with("articles",$articles);
//        return Article::all();

    }
    public function detail($id){
        $article=new Article();
        $article=Article::findOrFail($id);
//        if(!$article)
//            abort("404");
        return view("articles.detail")->with("article",$article);
    }
    public function addarticle(Article $articlemodel){
        $a=[
            "title"=>"最新文章".Carbon::now(),
            "content"=>"雏田哦",
            "published_at"=>Carbon::now(),
        ];
//        dump(Article::create($a)->title);
        return Article::create($a)->id;
    }
}
